package handler

import (
	"github.com/gin-gonic/gin"
	"onerk4/zg5yk/ordering/api/client"
	"onerk4/zg5yk/ordering/api/enit/request"
	"onerk4/zg5yk/ordering/api/enit/response"
	"onerk4/zg5yk/ordering/common/proto/takeout"
)

func ShowTakeoutList(c *gin.Context) {
	var req request.ShowTakeoutList

	if err := c.ShouldBind(&req); err != nil {
		response.ErrorResponse(c, "参数错误", err.Error())
		return
	}

	list, err := client.ShowTakeoutList(c, &takeout.ShowTakeoutListRequest{
		IsHot:     req.IsHot,
		IsPremium: req.IsPremium,
		IsSetMenu: req.IsSetMenu,
	})
	if err != nil {
		response.ErrorResponse(c, "err", err.Error())
		return
	}
	response.SuccessResponse(c, "ok", list)
}

func UserRecommend(c *gin.Context) {
	userId := c.GetUint("userId")

	recommend, err := client.UserRecommend(c, &takeout.UserRecommendRequest{
		UserId: int64(userId),
	})
	if err != nil {
		response.ErrorResponse(c, "err", err.Error())
		return
	}
	response.SuccessResponse(c, "ok", recommend)
}
